package com.test.designpattern.proxy.dynamic.cglib.service.impl;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.json.JSONUtil;
import com.test.designpattern.proxy.dynamic.cglib.entity.User;
import com.test.designpattern.proxy.dynamic.cglib.service.IUserService;

import java.util.List;

/**
 * 代理的目标
 */
public class UserServiceImpl implements IUserService {
    @Override
    public int save(User user) {
        System.out.println("添加了用户：" + JSONUtil.toJsonStr(user));
        return 1;
    }

    @Override
    public List<User> queryList() {
        User u1 = new User(1, "张三");
        User u2 = new User(2, "李四");
        List<User> users = ListUtil.of(u1, u2);
        System.out.println("查询了用户：" + JSONUtil.toJsonStr(users));
        return users;
    }
}
